package com.zuofei.springcloud.listener;

import cn.hutool.log.Log;
import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
import org.apache.commons.io.monitor.FileAlterationObserver;

import java.io.File;

public class FileListener extends FileAlterationListenerAdaptor {

    @Override
    public void onFileCreate(File file) {
        Log.get("zuofei").info("文件名:{}",file.getAbsoluteFile());
    }

    @Override
    public void onFileChange(File file) {
        Log.get("zuofei").info("文件名:{}",file.getAbsoluteFile());
    }

    /**
     * 文件删除
     */
    public void onFileDelete(File file) {
        Log.get("zuofei").info("文件名:{}",file.getAbsoluteFile());
    }

    /**
     * 目录创建
     */
    public void onDirectoryCreate(File directory) {
        Log.get("zuofei").info("文件夹:{}",directory.getAbsoluteFile());
    }

    /**
     * 目录修改
     */
    public void onDirectoryChange(File directory) {
        Log.get("zuofei").info("文件夹:{}",directory.getAbsoluteFile());
    }

    /**
     * 目录删除
     */
    public void onDirectoryDelete(File directory) {
        Log.get("zuofei").info("文件夹:{}",directory.getAbsoluteFile());
    }

    public void onStart(FileAlterationObserver observer) {
        // TODO Auto-generated method stub
        super.onStart(observer);
    }

    public void onStop(FileAlterationObserver observer) {
        // TODO Auto-generated method stub
        super.onStop(observer);
    }
}
